home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / showbcb.arc / BCB.ASM next >
Encoding:
Assembly Source File  |  1987-01-04  |  9.6 KB  |  423 lines

  1. title    BCB.ASM        Finds Concurrent PC-DOS disk buffers & control blocks
  2.  
  3. dos        equ    33        ; PC-DOS entry point
  4. wrt_dev        equ    40h        ;    write to device
  5. ccpm        equ    224        ; Concurrent entry point
  6. s_sysdat    equ    9Ah        ;     get system data segment
  7.  
  8. std_out        equ    1        ; standard output file handle
  9.  
  10. dph        equ    0C18h        ; offset of dph table in sysdat
  11. dpb        equ    8        ; offset of dpb in dph
  12. dirbcb        equ    0Eh        ; offset of dirbcb in dph
  13. datbcb        equ    10h        ; offset of datbcb in dph
  14. bcblr        equ    0        ; offset of bcb link list root bcbh
  15. mbcbp        equ    2        ; offset of max bcb per process in bcbh
  16. bufad        equ    0Ah        ; offset of ptr to buffer in bcb
  17. link        equ    0Ch        ; offset of ptr to nxt bcb in bcb
  18.  
  19. cr        equ    0Dh
  20. lf        equ    0Ah
  21.  
  22. wpt    equ    word ptr
  23. bpt    equ    byte ptr
  24. jmps     macro    x
  25.     jmp short
  26.      endm
  27.  
  28. int_tab    SEGMENT AT 0
  29.     ORG    ccpm*4
  30. ccpm_entry    dw    ?
  31.  
  32. int_tab    ENDS
  33.  
  34. cseg    SEGMENT word public 'CODE'
  35.     ASSUME    cs:cseg, ds:cseg, es:cseg, ss:cseg
  36.  
  37.     ORG    100h
  38.  
  39. main    PROC    near
  40.  
  41.     xor    AX,AX            ; make sure running under Concurrent
  42.     push    DS
  43.     mov    DS,AX
  44.     assume    DS:int_tab
  45.     cmp    AX,ccpm_entry
  46.     pop    DS
  47.     assume    DS:cseg
  48.     jnz    its_ccpm
  49.     mov    SI,offset not_ccpm
  50.     call    display
  51.     jmp    exit
  52. its_ccpm:
  53.     mov    SI,offset signon
  54.     call    display
  55.  
  56.     push    ES            ; get system data segment location
  57.     mov    CL,s_sysdat
  58.     int    ccpm
  59.     mov    AX,ES
  60.     pop    ES
  61.     mov    sd_ofs,BX        ; save system data offset
  62.     mov    sd_seg,AX        ; save system data segment
  63.     mov    DI,offset sdat_hex+5
  64.     call    word_2_hex
  65.     mov    DI,offset sdat_hex
  66.     mov    BX,sd_seg
  67.     call    word_2_hex
  68.  
  69.     mov    SI,offset sdat_msg
  70.     call    display
  71.  
  72.     push    DS
  73.     mov    DS,sd_seg        ; get system data segment
  74.  
  75.     mov    SI,ES:sd_ofs        ; get system data offset
  76.     add    SI,dph
  77.     mov    DI,offset dph_tbl    ; get disk parameter header addresses
  78.     mov    CX,12            ; 
  79.     rep    movsw
  80.  
  81.     mov    DI,offset dpb_tbl    ; get disk parameter block addresses
  82.     mov    BP,dpb
  83.     call    get_dph_fld
  84.  
  85.     mov    DI,offset dirbcb_tbl    ; get dir buffer ctl block addresses
  86.     mov    BP,dirbcb
  87.     call    get_dph_fld
  88.  
  89.     mov    DI,offset datbcb_tbl    ; get data buffer ctl block addresses
  90.     mov    BP,datbcb
  91.     call    get_dph_fld
  92.  
  93.     mov    SI,offset dirbcb_tbl    ; get max directory buffers per process
  94.     mov    DI,offset dirmbp_tbl
  95.     call    get_mbcbp
  96.  
  97.     mov    SI,offset datbcb_tbl    ; get max data buffers per process
  98.     mov    DI,offset datmbp_tbl
  99.     call    get_mbcbp
  100.  
  101.     mov    SI,offset dirbcb_tbl    ; get directory bcb hi, lo, and count
  102.     mov    DI,offset dirbcbhi_tbl
  103.     call    trace_bcblr
  104.  
  105.     mov    SI,offset datbcb_tbl    ; get data bcb hi, lo, and count
  106.     mov    DI,offset datbcbhi_tbl
  107.     call    trace_bcblr
  108.  
  109.     pop    DS
  110.  
  111.     mov    CX,12
  112.     xor    SI,SI
  113.     mov    BP,SI
  114. hex_lp:
  115.     push    CX
  116.     mov    BX,dph_tbl[SI]        ; convert dph to hex
  117.     lea    DI,dph_hex[BP]
  118.     call    word_2_hex
  119.     mov    BX,dpb_tbl[SI]        ; convert dpb to hex
  120.     lea    DI,dpb_hex[BP]
  121.     call    word_2_hex
  122.     mov    BX,dirbcb_tbl[SI]    ; convert dirbcb to hex
  123.     lea    DI,dirbcb_hex[BP]
  124.     call    word_2_hex
  125.     mov    BX,dirbcbhi_tbl[SI]    ; convert dir bcb hi to hex
  126.     lea    DI,dirbcbhi_hex[BP]
  127.     call    word_2_hex
  128.     mov    BX,dirbcblo_tbl[SI]    ; convert dir bcb lo to hex
  129.     lea    DI,dirbcblo_hex[BP]
  130.     call    word_2_hex
  131.     mov    BX,dirbufadhi_tbl[SI]    ; convert dir bufad hi to hex
  132.     lea    DI,dirbufadhi_hex[BP]
  133.     call    word_2_hex
  134.     mov    BX,dirbufadlo_tbl[SI]    ; convert dir bufad lo to hex
  135.     lea    DI,dirbufadlo_hex[BP]
  136.     call    word_2_hex
  137.     mov    BX,datbcb_tbl[SI]    ; convert datbcb to hex
  138.     lea    DI,datbcb_hex[BP]
  139.     call    word_2_hex
  140.     mov    BX,datbcbhi_tbl[SI]    ; convert dat bcb hi to hex
  141.     lea    DI,datbcbhi_hex[BP]
  142.     call    word_2_hex
  143.     mov    BX,datbcblo_tbl[SI]    ; convert dat bcb lo to hex
  144.     lea    DI,datbcblo_hex[BP]
  145.     call    word_2_hex
  146.     mov    BX,datbufadhi_tbl[SI]    ; convert dat bufad hi to hex
  147.     lea    DI,datbufadhi_hex[BP]
  148.     call    word_2_hex
  149.     mov    BX,datbufadlo_tbl[SI]    ; convert dat bufad lo to hex
  150.     lea    DI,datbufadlo_hex[BP]
  151.     call    word_2_hex
  152.  
  153.     shr    SI,1
  154.     mov    AL,dirmbp_tbl[SI]    ; convert dir mbcbp to hex
  155.     lea    DI,dirmbp_hex[BP]
  156.     call    byte_2_hex
  157.     mov    AL,dirbcbt_tbl[SI]    ; convert dir bcb totals to hex
  158.     lea    DI,dirbcbt_hex[BP]
  159.     call    byte_2_hex
  160.     mov    AL,datmbp_tbl[SI]    ; convert dat mbcbp to hex
  161.     lea    DI,datmbp_hex[BP]
  162.     call    byte_2_hex
  163.     mov    AL,datbcbt_tbl[SI]    ; convert dat bcb totals to hex
  164.     lea    DI,datbcbt_hex[BP]
  165.     call    byte_2_hex
  166.     shl    SI,1
  167.  
  168.     add    SI,2
  169.     add    BP,5
  170.     pop    CX
  171.     dec    CX
  172.     jz    display_info
  173.     jmp    hex_lp
  174.  
  175. display_info:
  176.     mov    SI,offset disk_info
  177.     call    display
  178.  
  179. exit:
  180.     mov    AH,4Ch
  181.     int    dos
  182.  
  183.     ; data area
  184.     ;
  185. signon    dw    signon_len
  186.     db    'Concurrent PC-DOS disk buffers and control blocks, '
  187.     db    'Howard Vigorita',cr,lf,lf
  188.     signon_len    equ    $-signon-2
  189.  
  190. sdat_msg    dw    sdat_msg_len
  191.         db    9,9,'System data segment located at '
  192. sdat_hex    db    'XXXX:XXXX',cr,lf
  193.         sdat_msg_len    equ    $-sdat_msg-2
  194.  
  195. disk_info    dw    disk_info_len
  196.     db    '            A:   B:   C:   D:   E:   F:   G:   H:   I:   K:   L:   M:'
  197.     db    cr,lf,lf,'dph        '
  198. dph_hex    db    12 dup ('XXXX ')
  199.     db    cr,lf,   'dpb        '
  200. dpb_hex    db    12 dup ('XXXX ')
  201.  
  202.     db    cr,lf,  '  dir:'
  203.     db    cr,lf,  'bcb header '
  204. dirbcb_hex    db    12 dup ('XXXX ')
  205.     db    cr,lf,   ' max/proc   '
  206. dirmbp_hex    db    12 dup ('XX   ')
  207.     db    cr,lf,   ' tot buffs  '
  208. dirbcbt_hex    db    12 dup ('XX   ')
  209.     db    cr,lf,   ' bcb hi    '
  210. dirbcbhi_hex    db    12 dup ('XXXX ')
  211.     db    cr,lf,   ' bcb lo    '
  212. dirbcblo_hex    db    12 dup ('XXXX ')
  213.     db    cr,lf,   ' bufadd hi '
  214. dirbufadhi_hex    db    12 dup ('XXXX ')
  215.     db    cr,lf,   ' bufadd lo '
  216. dirbufadlo_hex    db    12 dup ('XXXX ')
  217.  
  218.     db    cr,lf,  '  data:'
  219.     db    cr,lf,  'bcb header '
  220. datbcb_hex    db    12 dup ('XXXX ')
  221.     db    cr,lf,   ' max/proc   '
  222. datmbp_hex    db    12 dup ('XX   ')
  223.     db    cr,lf,   ' tot buffs  '
  224. datbcbt_hex    db    12 dup ('XX   ')
  225.     db    cr,lf,   ' bcb hi    '
  226. datbcbhi_hex    db    12 dup ('XXXX ')
  227.     db    cr,lf,   ' bcb lo    '
  228. datbcblo_hex    db    12 dup ('XXXX ')
  229.     db    cr,lf,   ' bufseg hi '
  230. datbufadhi_hex    db    12 dup ('XXXX ')
  231.     db    cr,lf,   ' bufseg lo '
  232. datbufadlo_hex    db    12 dup ('XXXX ')
  233.         disk_info_len    equ $-disk_info-2
  234.  
  235. not_ccpm    dw    not_ccpm_len
  236.         db    'Concurrent PC-DOS is required'
  237.         not_ccpm_len    equ    $-not_ccpm-2
  238.  
  239. sd_ofs        dw    ?
  240. sd_seg        dw    ?
  241. lo_addr        dw    ?
  242. hi_addr        dw    ?
  243.  
  244. dph_tbl        dw    12 dup (?)    ; pointers to dph's for drives A - M
  245. dpb_tbl        dw    12 dup (?)    ; pointers to dpb's for drives A - M
  246. dirbcb_tbl    dw    12 dup (?)    
  247. dirmbp_tbl    db    12 dup (?)    
  248. datbcb_tbl    dw    12 dup (?)    
  249. datmbp_tbl    db    12 dup (?)    
  250.  
  251. dirbcbhi_tbl    dw    12 dup (?)    
  252. dirbufadhi_tbl    dw    12 dup (?)    
  253. dirbcblo_tbl    dw    12 dup (?)    
  254. dirbufadlo_tbl    dw    12 dup (?)    
  255. dirbcbt_tbl    db    12 dup (?)
  256.  
  257. datbcbhi_tbl    dw    12 dup (?)
  258. datbufadhi_tbl    dw    12 dup (?)
  259. datbcblo_tbl    dw    12 dup (?)
  260. datbufadlo_tbl    dw    12 dup (?)
  261. datbcbt_tbl    db    12 dup (?)
  262.  
  263. main    ENDP
  264.  
  265.     ; subroutines
  266.     ;
  267.  
  268.     ; get buffer control block list root (word) from bcbh table
  269.     ; (pointed to by SI) and traces through the list, recording
  270.     ; hi & low addresses and counts in tables pointed to by DI
  271.     ; for drives A to M
  272.     ;
  273. trace_bcblr:
  274.     mov    CX,12            ; 12 drives, A to M
  275. trace_bcblr_lp:
  276.     xor    DX,DX            ; clear hi
  277.     mov    ES:hi_addr,DX
  278.     mov    BP,DX            ; clear lo
  279.     mov    ES:lo_addr,DX
  280.     mov    AX,DX            ; buffer counter
  281.     mov    BX,ES:[SI]        ; get bcbh pointer
  282.     add    SI,2
  283.     or    BX,BX
  284.     jz    sav_tots        ; skip if null (drive not implemented)
  285.     mov    BX,[BX]            ; get bcb list root
  286.     or    BX,BX
  287.     jz    sav_tots        ; skip if null
  288.     dec    BP
  289.     dec    ES:lo_addr
  290.  
  291. traverse:
  292.     inc    AL            ; increment buffer counter
  293.     cmp    DX,link[BX]        ; see if link new hi
  294.     ja    ck_hi_addr
  295.     mov    DX,link[BX]        ; if so, record it
  296. ck_hi_addr:
  297.     push    DX
  298.     mov    DX,ES:hi_addr
  299.     cmp    DX,bufad[BX]        ; see if buffer is hi
  300.     ja    ck_lo_addr
  301.     mov    DX,bufad[BX]        ; if so, record it
  302.     mov    ES:hi_addr,DX
  303. ck_lo_addr:
  304.     mov    DX,ES:lo_addr
  305.     cmp    DX,bufad[BX]        ; see if buffer is lo
  306.     jb    ck_lo
  307.     mov    DX,bufad[BX]        ; if so, record it
  308.     mov    ES:lo_addr,DX
  309. ck_lo:
  310.     pop    DX
  311.     cmp    wpt link[BX],0
  312.     lahf
  313.     jz    sav_tots
  314.     cmp    BP,link[BX]        ; see if new lo
  315.     jb    ck_tail
  316.     mov    BP,link[BX]        ; if so, record it
  317. ck_tail:
  318.     mov    BX,link[BX]        ; get the link
  319.     sahf                ; see if end
  320.     jnz    traverse        ; if not, do it again
  321.  
  322. sav_tots:
  323.     mov    BX,12
  324.     sub    BX,CX            ; calculate table offset
  325.     mov    ES:96[BX+DI],AL        ; save count
  326.     shl    BX,1            ; double offset for word tables
  327.     mov    ES:[DI+BX],DX        ; save hi bcb address
  328.     mov    DX,ES:hi_addr        ; save hi buffer address
  329.     mov    ES:24[DI+BX],DX
  330.     mov    ES:48[DI+BX],BP        ; save lo bcb address
  331.     mov    BP,ES:lo_addr        ; save lo buffer address
  332.     mov    ES:72[DI+BX],BP
  333.     dec    CX
  334.     jz    trace_x
  335.     jmp    trace_bcblr_lp
  336. trace_x:
  337.     ret
  338.  
  339.     ; gets maximum buffer control blocks per process (byte) from bcbh 
  340.     ; table (pointed to by SI) and put into a table pointed to by DI
  341.     ; for drives A to M
  342.     ;
  343. get_mbcbp:
  344.     mov    CX,12            ; 12 drives, A to M
  345. get_mbcbp_lp:
  346.     mov    AX,ES:[SI]        ; get bcbh pointer
  347.     add    SI,2
  348.     or    AX,AX
  349.     jz    no_mbcbp        ; skip if null (drive not implemented)
  350.     mov    BX,AX
  351.     mov    AL,mbcbp[BX]
  352. no_mbcbp:
  353.     stosb
  354.     loop    get_mbcbp_lp
  355.     ret
  356.  
  357.     ; gets dph field (specified by offset in BP) and puts
  358.     ; into a table pointed to by DI for drives A to M
  359.     ;
  360. get_dph_fld:
  361.     mov    SI,ES:sd_ofs        ; get system data offset
  362.     add    SI,dph            ; sysdat dph table
  363.     mov    CX,12            ; 12 drives, A to M
  364. get_dpb:
  365.     lodsw                ; get dph pointer
  366.     or    AX,AX
  367.     jz    no_dpb            ; skip if null (drive not implemented)
  368.     mov    BX,AX            ; move to index register
  369.     add    BX,BP
  370.     mov    AX,[BX]            ; get dpb ptr from dph
  371. no_dpb:
  372.     stosw                ; put into local table
  373.     loop    get_dpb
  374.     ret
  375.  
  376.     ; convert binary word in BX to ascii-hex and put in
  377.     ; buffer pointed to by DI
  378. word_2_hex:
  379.     mov    AL,BH
  380.     call    byte_2_hex
  381.     mov    AL,BL
  382.     call    byte_2_hex
  383.     ret
  384.  
  385.     ; convert binary byte in AL to ascii-hex and put in
  386.     ; buffer pointed to by DI
  387. byte_2_hex:
  388.     push    AX
  389.     call    nib_2_hex
  390.     pop    AX
  391.     mov    CL,4
  392.     shl    AL,CL
  393.     call    nib_2_hex
  394.     ret
  395.  
  396.     ; convert binary high order nibble in AL to ascii-hex and put in
  397.     ; buffer pointed to by DI
  398. nib_2_hex:
  399.     mov    CL,4
  400.     shr    AL,CL
  401.     cmp    AL,9
  402.     ja    over_9
  403.     add    AL,'0'
  404.     stosb
  405.     ret
  406. over_9:
  407.     add    AL,'A'-10
  408.     stosb
  409.     ret
  410.  
  411. display:
  412.     lodsw
  413.     mov    CX,AX
  414.     mov    DX,SI
  415.     mov    BX,std_out
  416.     mov    AH,wrt_dev
  417.     int    dos
  418.     ret
  419.  
  420. cseg    ENDS
  421.     END main
  422.  
  423.